/******************************************************************************
* File description: ModelConfigTabBar.qml
* Function: 自定义模型配置tabbar
* Current Version: 1.0.0
* Author: 张宇轩
* Date: 2024-08-07
*  -----
*  Copyright by 博坤生物 .
 *****************************************************************************/
import QtQuick 2.14
import QtQuick.Controls 2.14
import QtQuick.Layouts 1.14

TabBar {
    id: tabbar

    /* property 定义开始 */
    // 标题列表
    property var barTitleList: []

    // 私有

    // 信号
    signal currentIndexChanged(int index);


    // 方法

    /* property 定义结束 */

    bottomPadding: 4
    topPadding: 4
    bottomInset: 0
    spacing: 0

    background: Rectangle {
        color: "#FFD2EBFF"
        radius: 10
    }

    // tabButton
    Repeater {
        model: barTitleList

        TabButton {
            implicitHeight: parent.height

            // 文字
            contentItem: Label{
                id: text
                anchors.fill: parent
                font {
                    pixelSize: 16
                    bold: model.index === tabbar.currentIndex
                }
                verticalAlignment: Text.AlignVCenter
                horizontalAlignment: Text.AlignHCenter
                color: "#FF222222"
                text: qsTr(modelData)
            }

            // 背景
            background: Rectangle{
                color: model.index === tabbar.currentIndex ? "#FFFFFFFF" : "transparent"
                radius: 10
            }

            onClicked: tabbar.currentIndexChanged(index)
        }
    }
}
